package com.wlcorp.forcazamis.business.baseinfo.impl;

import java.util.List;

import com.wlcorp.forcazamis.business.baseinfo.IFeatureService;
import com.wlcorp.forcazamis.dao.baseinfo.IFeatureDAO;
import com.wlcorp.forcazamis.domain.baseinfo.Feature;
import com.wlcorp.forcazamis.exception.ServiceException;
import com.wlcorp.forcazamis.sys.BaseService;
import com.wlcorp.forcazamis.sys.util.AppConstant;

public class FeatureServiceImpl extends BaseService implements
		IFeatureService {
	
	private IFeatureDAO featureDAO;
	public List<Feature> getFeatureList(Feature feature)
			throws ServiceException {
		return featureDAO.getFeatureList(feature);
	}

	public Feature getFeatureById(Long featureId)
			throws ServiceException {
		if(null == featureId){
			return null;
		}
		return featureDAO.getFeatureById(featureId);
	}

	public void saveFeature(Feature feature) throws ServiceException {
		if(null == feature.getFeatureId()){
			List<?> featureList = featureDAO.getFeatureList(feature);
			if(featureList.size() > 0){
				setErrorField(feature,AppConstant.BASE_BEAN_STATUS_ERROR,"样品特征编号不能重复！");
				return;
			}
		}
		featureDAO.saveFeature(feature);
	}

	public void setFeatureDAO(IFeatureDAO featureDAO) {
		this.featureDAO = featureDAO;
	}

	public void deleteFeature(Feature feature) throws ServiceException {
		featureDAO.deleteFeature(feature);
	}
	
}
